﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;

namespace Sinacor.Servico.Bovespa.ContasCorrente.Service.ServiceImplementation.Translator
{
    public static class TranslateBetweenPosicaoContasCorrenteResponseAndPosicaoContasCorrente
    {
        public static DataContract.Response.PosicaoContasCorrenteResponse TranslatePosicaoContasCorrenteToPosicaoContasCorrenteResponse(BusinessEntity.PosicaoContasCorrente from)
        {
            if (from == null) return null;

            DataContract.Response.PosicaoContasCorrenteResponse to = new DataContract.Response.PosicaoContasCorrenteResponse();
            to.DataPosicao = from.DataPosicao;
            to.ContasCorrente = TranslateBetweenContaCorrenteResponseAndContaCorrente.TranslateContaCorrenteListToContaCorrenteResponseList(from.ContasCorrente);
            return to;
        }

        public static BusinessEntity.PosicaoContasCorrente TranslatePosicaoContasCorrenteResponseToPosicaoContasCorrente(DataContract.Response.PosicaoContasCorrenteResponse from)
        {
            if (from == null) return null;

            BusinessEntity.PosicaoContasCorrente to = new BusinessEntity.PosicaoContasCorrente();
            to.DataPosicao = from.DataPosicao;
            to.ContasCorrente = TranslateBetweenContaCorrenteResponseAndContaCorrente.TranslateContaCorrenteResponseListToContaCorrenteList(from.ContasCorrente);
            return to;
        }

        public static List<
         Sinacor.Servico.Bovespa.ContasCorrente.Service.DataContract.Response.PosicaoContasCorrenteResponse>
         TranslatePosicaoContaCorrenteListToPosicaoContaCorrenteResponseList(List<Sinacor.Servico.Bovespa.ContasCorrente.BusinessEntity.PosicaoContasCorrente> from)
        {

            if (from == null) return null;
            List<Sinacor.Servico.Bovespa.ContasCorrente.Service.DataContract.Response.PosicaoContasCorrenteResponse> to = new List<Sinacor.Servico.Bovespa.ContasCorrente.Service.DataContract.Response.PosicaoContasCorrenteResponse>();
            foreach (Sinacor.Servico.Bovespa.ContasCorrente.BusinessEntity.PosicaoContasCorrente fromItem in from)
            {
                to.Add(TranslatePosicaoContasCorrenteToPosicaoContasCorrenteResponse(fromItem));
            }
            return to;

        }
    }
}
